package com.example;

/**
 * @author yeqiang
 * @since 2021/8/16 下午2:03
 */
public class VolatileSample {

    volatile static VolatileSample volatileSampleInstance = null;
//    static VolatileSample volatileSampleInstance = null;

    private VolatileSample() {
    }

    public static VolatileSample getInstance() {
        if (volatileSampleInstance == null) {
            synchronized (VolatileSample.class) {
                if (volatileSampleInstance == null) {
                    volatileSampleInstance = new VolatileSample();
                }
            }
        }
        return volatileSampleInstance;
    }

    public static void main(String[] args) throws InterruptedException {
        System.out.println("zzzzzzzzzz");
        VolatileSample.getInstance();
    }
}
